﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace SkyNote.Domain
{
    internal class ObjectHelper
    {
        public static void CopyToObject<T>(object sourceObject, ref T destObject)
        {
            if (sourceObject != null && destObject != null)
            {
                Type type = sourceObject.GetType();
                Type type2 = destObject.GetType();
                PropertyInfo[] properties = type.GetProperties();
                for (int i = 0; i < properties.Length; i++)
                {
                    PropertyInfo propertyInfo = properties[i];
                    PropertyInfo property = type2.GetProperty(propertyInfo.Name);
                    if (!(property == null))
                    {
                        property.SetValue(destObject, propertyInfo.GetValue(sourceObject, null), null);
                    }
                }
            }
        }
    }
}
